//------------------------------------------------------------------------------
#include "CColumnModel.h"
//------------------------------------------------------------------------------
CColumnModel::CColumnModel(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
							QIcon *icon, Qt::ItemFlags flags, QVariant data, QVariant::Type type)
{
	_numChamp=numChamp;
	_nomChamp=nomChamp;
	_titre=titre;
	_alignment=alignment;
	_icon=icon;
	_flags=flags;
	_data=data;
	_type=type;
	_validator=NULL;
}
//------------------------------------------------------------------------------
CColumnModelString::CColumnModelString(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
										QIcon *icon, Qt::ItemFlags flags, QVariant data) : 
		CColumnModel(numChamp, nomChamp, titre, alignment, icon, flags, data)
{
	_defaultValue="";
}
//------------------------------------------------------------------------------
CColumnModelInt::CColumnModelInt(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
									QIcon *icon, Qt::ItemFlags flags, QVariant data) :
		CColumnModel(numChamp, nomChamp, titre, alignment, icon, flags, data, QVariant::Int)
{
	_defaultValue="0";
}
//------------------------------------------------------------------------------
CColumnModelDouble::CColumnModelDouble(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
										QIcon *icon, Qt::ItemFlags flags, QVariant data) :
		CColumnModel(numChamp, nomChamp, titre, alignment, icon, flags, data, QVariant::Double)
{
	_defaultValue="0.00";
}
//------------------------------------------------------------------------------
QString CColumnModelDouble::format(QString string) {
	int nbDecimal=2;
	
	if(_data.isValid()) {
		nbDecimal=_data.toInt();
	}
	
	return QString("%1").arg(string.toDouble(), 0, 'f', nbDecimal);
}
//------------------------------------------------------------------------------
CColumnModelDate::CColumnModelDate(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
									QIcon *icon, Qt::ItemFlags flags, QVariant data) :
		CColumnModel(numChamp, nomChamp, titre, alignment, icon, flags, data, QVariant::Date)
{
	_defaultValue=QDate::currentDate().toString("dd/MM/yyyy");
}
//------------------------------------------------------------------------------
CColumnModelTime::CColumnModelTime(	int numChamp, QString nomChamp, QString titre, Qt::Alignment alignment, 
									QIcon *icon, Qt::ItemFlags flags, QVariant data) :
		CColumnModel(numChamp, nomChamp, titre, alignment, icon, flags, data, QVariant::Time)
{
	_defaultValue=QTime::currentTime().toString("hh:mm:ss");
}
//------------------------------------------------------------------------------